<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

/**
 * 审核信息数据表
 *
 * Date: 19/03/2018
 * @author George
 */
class CreateAuditsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('audits', function (Blueprint $table) {
            $table->increments('id');
			$table->morphs('auditable');	// 定义多态关联字段
			$table->unsignedInteger('company_id')->default(0)->index()->comment('公司ID');
			$table->unsignedInteger('proposer')->default(0)->index()->comment('申请人ID');
			$table->nullableMorphs('approver');
			$table->string('status')->default('pending')->comment('状态');
			$table->string('comment')->nullable()->comment('批注');
			$table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('audits');
    }
}
